package com.example.journalegocentrique;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

//Helper class to adapt images to initial ListView

public class ImageAdapter extends BaseAdapter {

	private Context mContext;
	private int land;
    public ImageAdapter(Context c,int i) {
        mContext = c;
        land=i;
    }

    public int getCount() {
        return mThumbIds.length;
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }

    //Create a new ImageView for each item referenced by the Adapter
    
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            imageView = new ImageView(mContext);
            if(land==0)
            {
            	imageView.setLayoutParams(new GridView.LayoutParams(100, 100));
            	imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            	imageView.setPadding(6 , 6, 6, 6);
            }
            else
            {
            	imageView.setLayoutParams(new GridView.LayoutParams(80, 80));
            	imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            	imageView.setPadding(2 , 2, 2, 2);
            }
        } else {
            imageView = (ImageView) convertView;
        }

        imageView.setImageResource(mThumbIds[position]);
        return imageView;
    }

    // references to our images
	private Integer[] mThumbIds = { R.drawable.emoticon1, R.drawable.emoticon2,
			R.drawable.emoticon3, R.drawable.emoticon4, R.drawable.emoticon5,
			R.drawable.emoticon6, R.drawable.emoticon7, R.drawable.emoticon8,
			R.drawable.emoticon9, R.drawable.emoticon10, R.drawable.emoticon11 };
}
